package com.solution.admin.quartz;

import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.solution.admin.order.service.OrderService;

/**
 * 订单结束任务,终止过期订单
 * 24h时不支付自动取消定单，第小时跑一次
 * @author xkl
 * @date 2018年1月6日 下午4:29:12
 */
public class OrderTimedTask{

	@Autowired
	private OrderService orderService;
	
	/**
	 * 业务逻辑
	 */
	public void execute() {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(new Date());
		calendar.add(Calendar.DATE, -1);
		Date date = calendar.getTime();
		try {
			Map<String, Object> paramMap = new HashMap<String, Object>();
			paramMap.put("endDate", date);
			orderService.closeExpiredOrder(paramMap);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
